package design.mode.strategy.item1;

import java.util.HashMap;
import java.util.Map;

/**
 * 策略类是无状态的，不包含成员变量
 */
public class StrategyFactory {
    private static final Map<String,Strategy> strategies = new HashMap<>();

    static {
        strategies.put("A",new ConcreteStrategyA());
        strategies.put("B",new ConCreteStrategyB());
    }

    public static Strategy getStrategy(String type){
        if (type == null || type.isEmpty()){
            throw new IllegalArgumentException("");
        }
        return strategies.get(type);
    }
}
